package web;

import service.ArticlesService;
import pojo.Article;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

/**
 * @author fire'ge
 */
@WebServlet("/checkArticlesServlet")
public class CheckArticlesServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List<Article> articles = null;
        try {
            articles = ArticlesService.getArticleList();
            System.out.println(articles);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        request.setAttribute("articles",articles);
        request.setAttribute("loop","true");
        System.out.println("here");
        request.getRequestDispatcher("/jsp/ArticleLobby.jsp")
                .forward(request,response);

    }
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

}
